package com.itheima.reggie.entity;

import lombok.Data;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

@Data
public class Result<T> implements Serializable {

    private static final  long serialVersionUID = 1L ;
    //判断是否验证成功
    private Integer code;
    //错误信息
    private String msg ;
    //数据
    private T data ;
    //动态数据
    private Map map = new HashMap();

    public static <T>Result<T> success( T object){
        Result<T> tResult = new Result<>();
        tResult.setCode(1);
        tResult.setData(object);
        return tResult ;
    }

    public static Result error( String msg ){
        Result result = new Result();
        result.setCode(0);
        result.setMsg(msg);
        return result ;
    }

    public Result add( String key , Object value ){
        this.map.put(key , value);
        return this ;
    }

}
